package net.techwatch.contacts.shared;

import java.io.Serializable;

public class Contact implements Serializable {

	private String firstName;
	private String lastName;
	private String mailAddress;
	
	public Contact() {
		
	}
	public Contact(String firstName, String lastName, String mailAddress) {
		super();
		this.firstName = firstName;
		this.lastName = lastName;
		this.mailAddress = mailAddress;
	}
	
	public String getFirstName() {
		return firstName;
	}
	
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	
	public String getLastName() {
		return lastName;
	}
	
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	
	public String getMailAddress() {
		return mailAddress;
	}
	
	public void setMailAddress(String mailAddress) {
		this.mailAddress = mailAddress;
	}
	
	@Override
	public int hashCode() {
		return firstName.hashCode() + lastName.hashCode() + mailAddress.hashCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null)
			return false;
		
		if(obj instanceof Contact) {
			Contact c = (Contact) obj;
			boolean result = c.getFirstName().equals(getFirstName());
			result &= c.getLastName().equals(getLastName());
			result &= c.getMailAddress().equals(getMailAddress());
			
			return result;
		}
		
		return false;
	}
	
}
